﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 类型转换
{
    class Program
    {
        enum Sex
        {
            male,
            female
        }
        struct student
        {
            public string name;
            public int cardint;
        }
    
        static void Main(string[] args)
        {
            double a = 1.0;
            int b = (int)a;//先转化成int再赋值
                           //convert.Toint32,比较通用，parse只适用于字符串
            Sex mysex = Sex.female;//枚举，在前面定义
            Console.WriteLine((int)mysex);
            Console.WriteLine(mysex.ToString());
             //使用数组，循环语句，输入十个数，求均值
             //int[] arry = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            //int[] arry= new int[10];
            //Console.WriteLine("输入十个数");
            //for (int i = 0; i < arry.Length; i++)
            //{
                
            //    arry[i] = Int32.Parse(Console.ReadLine());
            //}
            //Console.WriteLine($"Average of these numbers is {arry.Average()}" );
            //
            int[] arry10 = { 97, 65, 32, 17, 58, 43, 79, 81, 23, 10 };
            //int nummax = arry10[0] ;
            //int nummin = arry10[0];

            //foreach (int i in arry10)
            //{
            //    if (i<nummin)
            //    {
            //        nummin = i;
            //        Console.WriteLine("最小的数是：{0}",i);
            //    }

            //}
            int[] array = { 97, 65, 32, 17, 58, 43, 79, 81, 23, 10 };
            Console.Write("数组排序前的结果为：");
            foreach (int  n in array)
            {
                Console.Write("{0}", n + " ");
            }
            Console.WriteLine();
            for (int i = 0; i < array.Length; i++)
            {
                for (int j = i; j < array.Length; j++)
                {
                    if (array[i]<array[j])
                    {
                        int temp = array[i];
                        array[i] = array[j];
                        array[j] = temp;
                    }
                }
            }
            Console.Write("数组排序后的结果为：");
            foreach (int n in array)
            {
                Console.Write("{0}", n + " ");
            }
            //Console.ReadLine();






            Console.ReadKey();

        }
    }
}
